TARGET = main
DEBUG_FLAGS= -g -Werror -std=c++17 -D__REFACTOR__


SRC_NAME = 	$(patsubst %.cpp, %, $(wildcard *.cpp))   \
            $(patsubst %.c, %, $(wildcard *.c))


BIN_NAME =  $(patsubst %.cpp, %, $(wildcard Test*.cpp)) 

CC=gcc
CXX=g++

INC_PATH += 
LIB_PATH += 

THIRD_ROOT = $(HOME)/third

GTEST_ROOT = $(THIRD_ROOT)
INC_PATH += $(GTEST_ROOT)/gtest
LIB_PATH += $(GTEST_ROOT)/gtest/gtest
STATIC_LIBS += gtest_main

#BOOST_ROOT=$(THIRD_ROOT)/boost_1_72_0
#INC_PATH += $(BOOST_ROOT)
#LIB_PATH += $(BOOST_ROOT)/stage/lib
#STATIC_LIBS += boost_thread

STATIC_LIBS += pthread dl  

CFLAGS= $(addprefix -I, $(INC_PATH)) $(DEBUG_FLAGS)
LFLAGS= $(DEBUG_FLAGS) $(addprefix -L, $(LIB_PATH))  $(addprefix -l, $(STATIC_LIBS)) /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.71.0

OBJS=$(addsuffix .o, $(SRC_NAME))

#BINS=$(addsuffix .exe, $(BIN_NAME))

all: $(TARGET) #$(BINS)

run: $(TARGET)
	./main

$(TARGET): $(OBJS)
	$(CXX) -o $@ $(OBJS) $(LFLAGS) 

$(BINS): $(OBJS)

%.exe: %.o
	$(CXX) -o $@ $(OBJS) $(LFLAGS)

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o: %.cpp
	$(CXX) $(CFLAGS) -c $<

clean: 
	rm -frv $(TARGET) $(OBJS) *.o  *.db $(BINS)
